package com.aaa.controller.mht;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.mht.QuestionMht;
import com.aaa.entity.mht.ViewTestResultmht;
import com.aaa.entity.scl.TestResultScl;
import com.aaa.entity.scl.ViewTestResultScl;
import com.aaa.service.mht.ViewTestResultService;
import com.aaa.service.scl.TestResultSclService;
import com.github.pagehelper.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Mht视图表控制层
 *
 * @author makejava
 * @since 2022-09-02 20:01:28
 */
@RestController
@RequestMapping("viewTestResultMht")
public class ViewTestResultMhtController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ViewTestResultService viewTestResultService;


    @RequestMapping(value = "queryAllByCondition.do", method = RequestMethod.GET)
    public Result queryAllByCondition(PageSortEntity pageSortEntity, ViewTestResultmht viewTestResultmht) {
        List<ViewTestResultmht> viewTestResultMhtList = viewTestResultService.queryAllByCondition(pageSortEntity, viewTestResultmht);
        Page page = (Page) viewTestResultMhtList;

        return success(page.getResult(), page.getTotal());
    }
    /**
     * 新增数据
     *
     * @param viewTestResultmht 实体
     * @return 新增结果
     */
    @RequestMapping(value = "queryById.do")
    public Result queryById(ViewTestResultmht viewTestResultmht){
        ViewTestResultmht viewTestResultScl1 = viewTestResultService.queryAll(viewTestResultmht);
        return success(viewTestResultScl1);
    }

    /**
     * 报表统计mht
     */
    @RequestMapping("queryAll.do")
    public Result queryAll() {
        Map<String, Integer> stringIntegerMap = viewTestResultService.queryResultAll();
        return success(stringIntegerMap);
    }

    /**
     * 删除计划
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping(value = "delViewMhtById.do")
    public Result deleteById(Integer id) {
        Boolean i = viewTestResultService.deleteById(id);
        if ( i ){
            return success();
        }else {
            return fail();
        }
    }

    /**
     *  批量删除计划
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping(value = "delViewMhtAllById.do")
    public Result deleteBatch(int [] id) {
        Integer integer = viewTestResultService.delTestPlanBatch(id);
        if (integer>0){
            return success();
        }else {
            return fail();
        }
    }

}

